package com.example.design_pattern.Observer.details;

import java.util.ArrayList;
import java.util.List;

public class Teacher {
    private List<Student> students=new ArrayList<>();
    private String message;

    public void addStudent(Student stu) {
        students.add(stu);
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
        notifyAllStu();
    }
    private void notifyAllStu() {
        for (Student stu : students) {
            stu.accept();
        }
    }
}
